//
//@File    :	15.2_tv.cpp
//@Time    :	2022/03/08 16:13:06
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	methods for the Tv class (Rempte methods are inline)
//

#include <iostream>
#include "15.1_tv.h"
//volume音量调高
bool Tv::volup()
{
    if (volume<MaxVal)
    {
        volume++;
        return true;
    }
    else{
        return false;
    }
}
//音量调低
bool Tv::voldown(){
    if (volume>MinVal){
        volume--;
        return true;
    }else{
        return false;
    }
}
//频道加
void Tv::chanup(){
    if (channel<maxchannel)
    {
        channel++;
    }else{
        channel=1;//加到最大时,变成最小,保证循环
    }
}

//频道减
void Tv::chandown(){
    if (channel>1)
    {
        channel--;
    }else{
        channel=maxchannel;//减到最小时,变成最大,保证循环
    }
}

void Tv::settings() const{
    using std::cout;
    using std::endl;
    cout<<"Tv is "<<(state==Off?"Off":"On")<<endl;
    if (state==On)  
    {
        cout<<"Volume setting = "<<volume<<endl;
        cout<<"Channel setting = "<<channel<<endl;
        cout<<"Mode = "<<(mode==Antenna?"antenna":"cable")<<endl;
        cout<<"Input = "<<(input == TV?"TV":"DVD")<<endl;
    }
}